package com.xjrsoft.module.ureport.controller;


import com.xjrsoft.common.result.Response;
import com.xjrsoft.core.tool.node.ForestNodeMerger;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.module.base.service.IXjrBaseDataItemDetailService;
import com.xjrsoft.module.base.vo.RptFileManagerVo;
import com.xjrsoft.module.ureport.service.IXjrRptFileInfoService;
import com.xjrsoft.module.ureport.vo.RptFileInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 报表管理 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2020-12-10
 */
@RestController
@Api("报表注册模块")
@RequestMapping("/reports-file-info")
public class XjrRptFileInfoController {

    @Autowired
    private IXjrRptFileInfoService rptFileInfoService;
    @Autowired
    private IXjrBaseDataItemDetailService dataItemDetailService;


    /**
     * @Author:湘北智造-框架开发组
     * @Date:2020/12/18
     * @Param:[]
     * @return:com.xjrsoft.common.result.Response
     * @Description:报表管理分页管理
     */
    @GetMapping("/tree")
    @ApiOperation("报表管理分页管理")
    public Response tree() {
        // 查询报表分类的数据字典明细
        List<RptFileManagerVo> detailList = BeanUtil.copyList(dataItemDetailService.getDataItemDetailListByCode("ReportSort", null), RptFileManagerVo.class);
        List<RptFileInfoVo> rptFileInfoList = BeanUtil.copyList(rptFileInfoService.list(), RptFileInfoVo.class);
        rptFileInfoService.buildRptFileInfoTree(detailList, rptFileInfoList);
        return Response.ok(ForestNodeMerger.merge(detailList));
    }
}
